//这里放的是路由规则
import {createRouter,createWebHashHistory,} from 'vue-router'

//1.定义路由组件
import PageTopicLibraryManage from '@/pages/secondary_page/PageTopicLibraryManage';
import Pageaddress from '@/pages/secondary_page/Pageaddress';
import Pagefinancing from '@/pages/secondary_page/Pagefinancing';
import Pageindustry from '@/pages/secondary_page/Pageindustry';
import Pagetreatment from '@/pages/secondary_page/Pagetreatment';
import Pageposition from '@/pages/secondary_page/Pageposition';
import Pagezhiwei from '@/pages/secondary_page/Pagezhiwei';
import Pageskill from '@/pages/secondary_page/Pageskill';

import PageArticleManage from '@/pages/secondary_page/PageArticleManage';//文章管理
import PageUserManage from '@/pages/secondary_page/PageUserManage';//用户管理
import PageRiderManage from '@/pages/secondary_page/PageRiderManage';//骑手
import PageStoreManage from '@/pages/secondary_page/PageStoreManage';//商店
import PageTopicManage from '@/pages/secondary_page/PageTopicManage';//题目管理
import PageUserNote from '@/pages/secondary_page/PageUserNote';//用户笔记
import PageTopicCollect from '@/pages/secondary_page/PageTopicCollect';//题目收藏
import PageArticleCollect from '@/pages/secondary_page/PageArticleCollect';//文章收藏
import PageCompanyCollect from '@/pages/secondary_page/PageCompanyCollect';//企业收藏
import PageCommentCollect from '@/pages/secondary_page/PageCommentCollect';//评论收藏
import PageSecondCommentCollect from '@/pages/secondary_page/PageSecondCommentCollect';//二级评论收藏
import PageMessageNotice from '@/pages/secondary_page/PageMessageNotice';//消息通知
import PageDynamicNotice from '@/pages/secondary_page/PageDynamicNotice';//动态通知
import PagePrivateNotice from '@/pages/secondary_page/PagePrivateNotice';//私信通知
import PageUserComment from '@/pages/secondary_page/PageUserComment';//私信通知
import PageUserSecondComment from '@/pages/secondary_page/PageUserSecondComment';//私信通知
import PageLikeArticle from '@/pages/secondary_page/PageLikeArticle';//私信通知
import PageLikeComment from '@/pages/secondary_page/PageLikeComment';//私信通知
import PageLikeSecondComment from '@/pages/secondary_page/PageLikeSecondComment';//私信通知
import PageCollectNotice from '@/pages/secondary_page/PageCollectNotice';//私信通知


// 2. 定义一些路由
// 每个路由都需要映射到一个组件。
// 我们后面再讨论嵌套路由。 
const routes = [
    { path: '/topicLibrary', component: PageTopicLibraryManage },
    { path: '/address', component: Pageaddress },
    { path: '/financing', component: Pagefinancing },
    { path: '/industry', component: Pageindustry },
    { path: '/treatment', component: Pagetreatment },
    { path: '/postAsk', component: Pageposition },
    { path: '/zhiwei', component: Pagezhiwei },
    { path: '/skill', component: Pageskill },
    { path: '/article', component: PageArticleManage },
    { path: '/user', component: PageUserManage },
    { path: '/rider', component: PageRiderManage },
    { path: '/store', component: PageStoreManage },
    { path: '/topic', component: PageTopicManage },
    { path: '/note', component: PageUserNote },
    { path: '/topicCollect', component: PageTopicCollect },
    { path: '/articleCollect', component: PageArticleCollect },
    { path: '/companyCollect', component: PageCompanyCollect },
    { path: '/commentCollect', component: PageCommentCollect },
    { path: '/secondCommentCollect', component: PageSecondCommentCollect },
    { path: '/messageNotice', component: PageMessageNotice },
    { path: '/dynamicNotice', component: PageDynamicNotice },
    { path: '/privateNotice', component: PagePrivateNotice },
    { path: '/comment', component: PageUserComment },
    { path: '/secondComment', component: PageUserSecondComment },
    { path: '/likeArticle', component: PageLikeArticle },
    { path: '/likeComment', component: PageLikeComment },
    { path: '/likeSecondComment', component: PageLikeSecondComment },
    { path: '/collectNotice', component: PageCollectNotice },


    //传数传递第一种
    // { path: '/query', component:()=>import('@/pages/secondary_page/PageQuery'),uid:'', version:'1.0.2',s:''},
    //传数传递第二种
    // { path: '/restful/:uid/:type',component:()=>import('@/pages/secondary_page/PageRestful') },
    //如果路由没有匹配到，显示404
    { path: '/:pageMatch(.*)*', component:()=>import('@/pages/PageNotFound')},
    { path: '/login', component:()=>import('@/pages/Login') },
  ]


// 3. 创建路由实例并传递 `routes` 配置
// 你可以在这里输入更多的配置，但我们在这里
// 暂时保持简单
const router = createRouter({
    // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
    //createWebHistory() 不带#号
    //createWebHashHistory() 带有#号
    history: createWebHashHistory(),
    routes, // `routes: routes` 的缩写
 })

 //前置路由守卫
 //to 到哪里去
 //from 从哪里来
 //next 下一步（放行）
router.beforeEach((to, from, next) => {
  //假装拦截
  // if(to.params.type == 0){
  //   next("/404")
  // }
  // console.log(to,from)
  next();
})
export default router
